home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Online / httpproxy / checkport.rexx < prev    next >
OS/2 REXX Batch file  |  1996-08-20  |  737b  |  41 lines

  1. /* Check whether one of several ARexx ports is already up */
  2.  
  3. call addlib('rexxsupport.library', 0, -30, 0)
  4. parse arg AllArgs
  5.  
  6. do forever
  7.    parse VAR AllArgs Name AllArgs
  8.    if Name == "" then
  9.       leave
  10.  
  11.    /* Check lonly port name and all names with .0 to .9 extensions */
  12.    do i=-1 to 9
  13.  
  14.       if i > -1 then
  15.      n = Name'.'i
  16.       else
  17.      n = Name
  18.  
  19.       call CheckPort(n)
  20.  
  21.       if i > -1 then
  22.      n = upper(Name)'.'i
  23.       else
  24.      n = upper(Name)
  25.  
  26.       call CheckPort(n)
  27.    end
  28. end
  29.  
  30. exit 20    /* no port found */
  31.  
  32. /* we do that by trying and opening one Name after another */
  33.  
  34. CheckPort: procedure
  35.    parse Arg n
  36.    myport = openport(n)
  37.    if myport = 0 then  /* port is already there */
  38.       exit 0
  39.    call closeport(n)
  40.    return
  41.